package ru.mcfr.oxygen.framework.operations.table;

import ro.sync.ecss.extensions.api.*;
import ro.sync.ecss.extensions.api.node.AuthorElement;
import ro.sync.ecss.extensions.api.node.AuthorNode;

import javax.swing.text.BadLocationException;

/**
 * Created by IntelliJ IDEA.
 * User: ws
 * Date: 4/14/11
 * Time: 1:27 PM
 * To change this template use File | Settings | File Templates.
 */
public class JoinCellInColumnOperation implements AuthorOperation {
    public void doOperation(AuthorAccess authorAccess, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {
        AuthorDocumentController controller = authorAccess.getDocumentController();
        if (!authorAccess.getEditorAccess().hasSelection()){
            try {
                AuthorNode selectedCell = controller.getNodeAtOffset(authorAccess.getEditorAccess().getCaretOffset());
                if (!selectedCell.getName().equalsIgnoreCase("ячейка"))
                    selectedCell = selectedCell.getParent();

                AuthorNode row = selectedCell.getParent();
                int cellNumber = 0;
                for (AuthorNode cell : ((AuthorElement) row).getContentNodes()){
                    if (cell == selectedCell)
                        break;
                    cellNumber += 1;
                }



            } catch (BadLocationException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }
    }

    public ArgumentDescriptor[] getArguments() {
        return new ArgumentDescriptor[0];  //To change body of implemented methods use File | Settings | File Templates.
    }

    public String getDescription() {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
